package sketchpad.gui.drawinggraph;

import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
import sketchpad.constant.CHNName;
import sketchpad.constant.Geometry;
import sketchpad.constant.SketchPadColor;
import sketchpad.gui.drawinggraph.node.Node;

import java.io.Serializable;

public class Triangle extends DrawItem implements Serializable {

    public Triangle(int id, Node node){
        super(id, node);
        setGeometryClass(Geometry.TRIANGLE);
        setLabel(CHNName.TRIANGLE);
    }

    @Override
    public void draw(Node mouseNode, GraphicsContext gc){
        double x5 = getLeftUpNode().x;
        double y5 = getLeftUpNode().y;
        double x6 = mouseNode.x;
        double y6 = mouseNode.y;
        setRightDownNode(new Node(x6,y6));
        if (!isSelect())gc.setStroke(Color.valueOf(SketchPadColor.COLOR_TRIANGLE));
        gc.strokeLine(x5,y5,x6,y6);
        gc.strokeLine(x6,y6,x5+x5-x6,y6);
        gc.strokeLine(x5+x5-x6,y6,x5,y5);
    }
}
